/**
 * Created by PanJiaChen on 16/11/18.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export const validateMoblie = (_, value, callback) => {
  if (/^1[3-9]\d{9}$/.test(value)) {
    callback()
  } else {
    callback(new Error('请输入正确的手机号'))
  }
}

export const validatorAge = (rules, value, callback) => {
  if (/^[1,9]\d{0,2}$/.test(value) && value <= 120) {
    callback()
  } else {
    callback(new Error('请输入正确的年龄'))
  }
}
